#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

const int kMaxN = 70;
const int kMaxA = 51;
int n, length;
int a[kMaxN], end_len[kMaxN];
int low_bound_res[kMaxA];
bool used[kMaxN] = {false};

bool DFS(int rest_stick, int no, int rest_len) {
  if (rest_len == 0) {
    rest_stick--;
    no = 0;
    rest_len = length;
  }
  if (rest_stick == 1) {
    return true;
  }
  for (int i = no; i < n; i++) {
    if (used[i] == false) {
      used[i] = true;
      rest_len -= a[i];
      if (DFS(rest_stick, max(i + 1, rest_len > a[0] ? 0 : low_bound_res[rest_len]), rest_len)) {
        return true;
      }
      rest_len += a[i];
      used[i] = false;
      i = end_len[i];
      // rest_len == length && end_len && low_bound_res for case 7 9 20 21 25 26 27
      // rest_len == a[i] for case 24 28 29 30
      if (rest_len == length || rest_len == a[i]) {
        break;
      }
    }
  }
  return false;
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

  int sum = 0;

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum += a[i];
  }

  sort(a, a + n);
  reverse(a, a + n);
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] != a[i + 1]) {
      end_len[i] = i;
    } else {
      end_len[i] = end_len[i + 1];
    }
  }
  low_bound_res[kMaxA - 1] = 0;
  for (int i = kMaxA - 2; i >= 0; i--) {
    for (low_bound_res[i] = low_bound_res[i + 1]; a[low_bound_res[i]] > i; low_bound_res[i]++);
  }

  for (length = a[0]; length <= sum; length++) {
    if (sum % length) {
      continue;
    }
    if (DFS(sum / length, 0, length)) {
      cout << length << endl;
      break;
    }
  }
  return 0;
}